<template>
  <div>
    <div class="tab flex">
      <div
        class="tab-item flex-xy-center"
        v-for="(item, index) in tabList"
        :key="index"
        :class="{ active: tabIndex === index }"
        @click="toggleTab(index)"
      >
        {{ item }}
      </div>
    </div>

    <div class="store-list" v-if="tabIndex == 0">
      <div
        class="store-item"
        v-for="(item, index) in 10"
        :key="index"
        @click="toProductDetail"
      >
        <div class="flex-y-center">
          <el-image :src="require('@/assets/img/test.png')" class="avatar"></el-image>
          <div class="info">
            <div class="name">商品名称</div>
            <div class="bottom-info  flex-x-bet-y-center">
              <div class="box flex-1 flex">
                <span class="content">2024-01-01 辽宁省沈阳市</span>
                <div class="price">52.25万</div>
              </div>
              <el-image
                :src="require('@/assets/img/ischeck.png')"
                class="is-check"
              ></el-image>
            </div>
          </div>
        </div>
        <div class="line"></div>
      </div>
    </div>


    <div class="store-list" v-if="tabIndex == 1">
      <div
        class="store-item"
        v-for="(item, index) in 10"
        :key="index"
        @click="toStoreDetail"
      >
        <div class="flex-y-center">
          <el-image :src="require('@/assets/img/test.png')" class="avatar"></el-image>
          <div class="info">
            <div class="name">店铺名称</div>
            <div class="bottom-info flex-y-center">
              <div class="box">
                <span class="title">主营业务：</span>
                <span class="content">挖掘机</span>
              </div>
              <div class="box">
                <span class="title">服务区域：</span>
                <span class="content">辽宁省 沈阳市</span>
              </div>
            </div>
          </div>
        </div>
        <div class="line"></div>
      </div>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
export default {
  name: "collect",

  data() {
    return {
      tabList: ["收藏的设备", "收藏的店铺"],
      tabIndex: 0,
      total: 20,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {},
  methods: {
    toggleTab(index) {
      this.tabIndex = index;
    },
    toStoreDetail() {
      this.$router.push("/storeDetail/collect");
    },
    toProductDetail(){
        this.$router.push("/productDetail/collect");
    }
  },
};
</script>

<style lang="scss" scoped>
.tab {
  background: #f7f7f7;
  padding-bottom: 20px;

  .tab-item {
    width: 140px;
    height: 40px;
    background: #ffffff;
    border-radius: 4px 4px 4px 4px;
    margin-right: 20px;
    font-weight: 400;
    font-size: 16px;
    color: #333333;
    cursor: pointer;
  }

  .active,
  .tab-item:hover {
    background: #fe5a13;
    color: #fff;
  }
}

.store-list {
  .store-item {
    position: relative;
    padding: 20px 20px 0 20px;
    background: #fff;

    .avatar {
      width: 80px;
      height: 80px;
      border-radius: 10px;
    }

    .info {
    flex:1;
      margin-left: 20px;

      .name {
        font-weight: bold;
        font-size: 16px;
        color: #333333;
      }

      .bottom-info {
        padding-top: 20px;

        .box {
          padding-right: 60px;
          font-weight: 400;
          font-size: 16px;
          .title {
            color: #808080;
          }

          .content {
            color: #333;
          }

          .price {
            color: #f42d1f;
            padding-left: 70px;
          }
        }

        .is-check {
          width: 106px;
          height: 33px;
        }
      }
    }
  }

  .line {
    margin: 20px -20px 0;
    background-color: #f7f7f7;
    height: 20px;
  }
}

::v-deep .pagination-container {
  width: 100%;
  padding: 50px 20px;
  box-sizing: border-box;
  background: #f7f7f7;
}
</style>
